package game.database.mysql;

import dou.database.IConnectionConfig;
import game.ServerConfig;

/**
 * Mysql 配置类
 * @author wizardc
 */
public class MysqlConfig implements IConnectionConfig
{
    private final static String _driverClass = "com.mysql.jdbc.Driver";
    private final static String _otherParam = "&useUnicode=true&characterEncoding=utf-8";

    @Override
    public String getDriverClass()
    {
        return _driverClass;
    }

    @Override
    public String getConnectionHost()
    {
        return ServerConfig.getInstance().getDBHost();
    }

    @Override
    public int getConnectionPort()
    {
        return ServerConfig.getInstance().getDBPort();
    }

    @Override
    public String getConnectionUsername()
    {
        return ServerConfig.getInstance().getDBUsername();
    }

    @Override
    public String getConnectionPassword()
    {
        return ServerConfig.getInstance().getDBPassword();
    }

    @Override
    public String getDatabase()
    {
        return ServerConfig.getInstance().getDBDatabase();
    }

    @Override
    public String getOtherParam()
    {
        return _otherParam;
    }

    @Override
    public String getConnectionString()
    {
        return "jdbc:mysql://"+getConnectionHost()+":"+getConnectionPort()+"/"+
        getDatabase()+"?user="+getConnectionUsername()+"&password="+
        getConnectionPassword()+getOtherParam();
    }
}
